from django.db import models
from django.core import validators


class UserModel(models.Model):
    """用户模型"""
    username = models.CharField(max_length=20, null=False)
    telphone = models.CharField(max_length=11, null=False, unique=True, validators=[validators.MinLengthValidator(limit_value=11)])
    password = models.CharField(max_length=12, null=False,
                                validators=[validators.MinLengthValidator(limit_value=6), validators.MaxLengthValidator(limit_value=12)])


class BookModel(models.Model):
    """图书模型"""
    title = models.CharField(max_length=100, null=False)
    pages = models.IntegerField(null=False, validators=(validators.MinValueValidator(limit_value=0),
                                                        validators.MaxValueValidator(limit_value=1000)))
    price = models.FloatField(null=False)

